#pragma once

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "OpenGL/stb_image.h"

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#include "Shader.h"
#include "Camera.h"
#include "Geo.h"
#include "SkyBox.h"

#include <iostream>
#include <atomic>
#include <mutex>
#include <thread>
#include <windows.h>

using namespace std;

class Device 
{
public:
	Device() 
	{
		camera = Camera(glm::vec3(0.0f, 0.0f, 15.0f));
		lightPos = glm::vec3(1.2f, 1.0f, 2.0f);
	};
	Device(unsigned int w, unsigned int h)
	{
		camera = Camera(glm::vec3(0.0f, 0.0f, 15.0f));
		lightPos = glm::vec3(1.2f, 1.0f, 2.0f);
		SCR_WIDTH = w;
		SCR_HEIGHT = h;
	};
	int init();
	int gameLoop();
	void processInput();
	void UpdateRender();
	void SingleThreadRun();

	void MultiThreadRun();
	void RenderThread();
	void SimulationThread();

	Camera* getCamera();
	Geo* getGeo();

private:
	SkyBox* skyBox;
	GLFWwindow* window;
	Shader* lampShader;
	// settings
	unsigned int SCR_WIDTH = 800;
	unsigned int SCR_HEIGHT = 600;

	// camera
	Camera camera;
	// lighting
	glm::vec3 lightPos;
	// geo
	Geo* geo;

	// multi thread
	atomic<bool> quit = false;
};